package com.qf.controller;

import com.qf.entity.po.User;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

@Controller
@ConfigurationProperties(prefix = "java")
@Slf4j
@Api(tags = {"案例模块"})
public class DemoController {

    private String name;
    private Integer age;
    private String info;

    @Value("${java.name}")
    private String name1;

    @GetMapping("info")
    @ResponseBody
    public String getInfo(){

        log.trace("跟踪级别--");
        log.debug("==Bug级别--");
        log.info("Info");
        log.warn("warn..");
        log.error("error..级别");

        return "Hello SpringBoot 3.0"+name+age+name1+"\t"+info;
    }

    @GetMapping("testInfo")
    public String testInfo(HttpServletRequest request){
        request.setAttribute("name","布洛妮娅");
        User user = new User();
        user.setName("希尔");
        user.setAge(18);
        user.setSex(0);
        request.setAttribute("user",user);

        request.setAttribute("msg1","<h2>普通字符串</h2>");

        //视图解析器 业务逻辑  classpath:/templates/   suffix: .html
        return "index";
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public void setInfo(String info) {
        this.info = info;
    }
}
